# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=tree-sitter-typescript
pkgver=0.20.1
pkgrel=0
pkgdesc="TypeScript grammar for tree-sitter"
url="https://github.com/tree-sitter/tree-sitter-typescript"
arch="all"
license="MIT"
makedepends="tree-sitter-dev"
provides="tree-sitter-tsx=$pkgver-r$pkgrel"
install_if="tree-sitter-grammars"
source="https://github.com/tree-sitter/tree-sitter-typescript/archive/v$pkgver/tree-sitter-typescript-$pkgver.tar.gz"
options="!check"  # no tests for shared lib

_langs='tsx typescript'

build() {
	local lang; for lang in $_langs; do
		abuild-tree-sitter build -s "$lang/src"
	done
}

package() {
	local querydir="$pkgdir/usr/share/tree-sitter/queries"

	local lang; for lang in $_langs; do
		DESTDIR="$pkgdir" abuild-tree-sitter install -s "$lang/src"
	done

	rm "$querydir"/tsx/*
	echo '; inherits: typescript' > "$querydir"/tsx/highlights.scm
	echo '; inherits: typescript' > "$querydir"/tsx/injections.scm
}

sha512sums="
4d57308e84964bbf136868285141c4cd28ae0bbddef7973849679f8b8b85f00cd1bb5a4db7fd7b5cbd6a090b56193c8120bfd134358d33597a60a9145c694de0  tree-sitter-typescript-0.20.1.tar.gz
"
